#include "FilterQuery.h"
#include <qDebug>
#include <QSqlError>
#include "../DatabaseException.h"


FilterQuery::FilterQuery()
{
}

FilterQuery::FilterQuery(const QString &command)
	:QSqlQuery(command)
{
}

QVariant FilterQuery::nextValue()
{
	return value(_valueIndex++);
}

QVariant FilterQuery::value(int i) const
{
	return QSqlQuery::value(i);
}

bool FilterQuery::next()
{
	_valueIndex = 0;
	return QSqlQuery::next();
}

void FilterQuery::exec()
{
	_valueIndex = 0;
	if (!QSqlQuery::exec())
	{
		throw TCServer::Store::DatabaseRunetimeException(*this);
	}
}

bool FilterQuery::prepare(const QString& query)
{
	return QSqlQuery::prepare(query);
}

void FilterQuery::addBindValueWithoutFilter(const QString &val, QSql::ParamType type /*= QSql::In*/)
{
	return QSqlQuery::addBindValue(val, type);
}

void FilterQuery::bindValue(const QString& placeholder, const QVariant& val, QSql::ParamType type /*= QSql::In*/)
{
	return QSqlQuery::bindValue(placeholder, val, type);
}

QString FilterQuery::executedQuery() const
{
	return QSqlQuery::executedQuery();
}

QVariant FilterQuery::lastInsertId() const
{
	return QSqlQuery::lastInsertId();
}

int FilterQuery::numRowsAffected() const
{
	return QSqlQuery::numRowsAffected();
}

QSqlError FilterQuery::lastError() const
{
    return QSqlQuery::lastError();
}
